package org.ssi.web.struts.bean;


public final class Pager {
	private static final long serialVersionUID = 1L;

	private int cpage = 1; // 当前页数

	private int allpage = 0; // 总页数

	private int pagesize = 20; // 每页记录数

	private int allcol = 0; // 总记录数

	private int previous = 1; // 上一页

	private int next = 1; // 下一页
	

	private String field = "";

	private String sort = "desc";

	public int getAllcol() {
		return allcol;
	}

	public int getAllpage() {
		return allpage;
	}

	public int getCpage() {
		return cpage;
	}

	public int getPagesize() {
		return pagesize;
	}

	public void setAllcol(int i) {
		allcol = i;	
		if(pagesize<=0){
			pagesize=10;
		}
		allpage = (allcol + pagesize - 1) / pagesize;

		if (getCpage() > getAllpage())
			setCpage(getAllpage());
		if (getCpage() < 1)
			setCpage(1);
		if (getAllpage() < 1)
			setAllpage(1);

		previous = cpage - 1;
		next = cpage + 1;

	}

	public void setAllpage(int i) {
		allpage = i;
	}

	public void setCpage(int i) {
		cpage = i;
	}

	public void setPagesize(int i) {
		pagesize = i;
	}

	public int getNext() {
		return next;
	}

	public int getPrevious() {
		return previous;
	}

	public void setNext(int i) {
		next = i;
	}

	public void setPrevious(int i) {
		previous = i;
	}

	public String getField() {
		return field;
	}

	public String getSort() {
		return sort;
	}

	public void setField(String string) {
		field = string;
	}

	public void setSort(String string) {
		sort = string;
	}

	public int getBeginPagesize() {
		return (cpage-1)*pagesize;
	}


	public int getEndPagesize() {
		return  cpage*pagesize;
	}

}
